package com.ctg.behavior.calc.impala.utils;

import com.ctg.behavior.client.impala.common.CtQueryResult;
import com.ctg.behavior.common.CtgResult;
import com.ctg.behavior.common.calc.CtCalcResult;
import com.ctg.behavior.common.consts.CtResultConsts;

public class CtCalculatorUtils {

	public static CtCalcResult fillCalcResult(CtgResult ctgResult, final CtQueryResult queryResult) {

		ctgResult.getExtInfo().put(CtResultConsts.EXT_IMPALA_SQL, queryResult.getSql());
		
		if (!queryResult.isSuccess()) {
			ctgResult.setSuccess(false);
			ctgResult.setErrorCode(queryResult.getCode());
			ctgResult.setErrorMessage(queryResult.getMsg());
		}

		return ctgResult;
	}

}
